define(function(require,exports,module){
    var Base={
		mBaserSvrUrl:window.BaseServerUrl,
		localStorage:window.localStorage
	};
	
	function JlnRequest(){
		this.params={}
	}
	module.exports=ValidationCodeProxy;
function ValidationCodeProxy(){
	function validationcodeSubmit(request, success, ignoreError) {
	    var url = Base.mBaserSvrUrl+'/validationcode';
        if (request.svr == null) request.svr = undefined;
	    if (request.token == null) request.token = undefined;
	    var content = JSON.stringify(request);
       
	    url = url + '?f=t&data=' + encodeURIComponent(content);
	    url = url + '&CallBack=?';
        $.getJSON(url,success);

	}

	function requestRq(union,key,success,ignoreError){
        var request=new JlnRequest();
        request.func='request';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['k']=key;

		if (union == true) {
	        request.svr = 'validationcode';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.requestRequest=function(key,success,ignoreError){
       var request= requestRq(true,key,success,ignoreError);
       return request;
    }
	this.request=function(key,success,ignoreError){
       var request= requestRq(false,key,success,ignoreError);
       validationcodeSubmit(request, success, ignoreError);

    }

	function validateCodeRq(union,code,key,success,ignoreError){
        var request=new JlnRequest();
        request.func='validateCode';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['c']=code;
		request.params['k']=key;

		if (union == true) {
	        request.svr = 'validationcode';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.validateCodeRequest=function(code,key,success,ignoreError){
       var request= validateCodeRq(true,code,key,success,ignoreError);
       return request;
    }
	this.validateCode=function(code,key,success,ignoreError){
       var request= validateCodeRq(false,code,key,success,ignoreError);
       validationcodeSubmit(request, success, ignoreError);

    }

	function freeRq(union,code,success,ignoreError){
        var request=new JlnRequest();
        request.func='free';
        request.token = Base.localStorage.getItem('request_token');
		
		request.params['c']=code;

		if (union == true) {
	        request.svr = 'validationcode';
            request.ignoreError = ignoreError;
	        request.success = success;
        }
	    return request;
    }
	this.freeRequest=function(code,success,ignoreError){
       var request= freeRq(true,code,success,ignoreError);
       return request;
    }
	this.free=function(code,success,ignoreError){
       var request= freeRq(false,code,success,ignoreError);
       validationcodeSubmit(request, success, ignoreError);

    }
}

});
